// 用户请求模块

import request from '../utils/request'
// import store from '@/store'
export const login = data => {
    return request({
        method: 'POST',
        url: 'v1_0/authorizations',
        data
    })
}

// 发送验证码接口
// 注意，每个手机号每分钟只能受到一次
export const sendSms = mobile => {
    return request({
        method: 'GET',
        url: `/v1_0/sms/codes/${mobile}`,
    })
}

// /v1_0/user 获取用户信息
export const getUserInfo = () => {
    return request({
        method: 'GET',
        url: '/v1_0/user/',
        // 发送请求头数据
        // headers:{
        //     // 该接口需要授权才能访问
        //     // token的数据格式:Bearer token数据 Bearer后面有个空格
        //     Authorization:`Bearer ${store.state.use.token}`
        // }
    })
}

//  /v1_0/user/channels 获取用户频道列表
export const getUserChannels = ()=> {
    return request({
        method: 'GET',
        url: '/v1_0/user/channels/',
    })
}

// 关注用户  /v1_0/user/followings

export const addFollow = target => {
    return request({
        method: 'POST',
        url: '/v1_0/user/followings/',
        data:{
            target
        }
    })
}
// 取消关注 /v1_0/user/followings/:target
export const deleteFollow = target => {
    return request({
        method: 'DELETE',
        url: `/v1_0/user/followings/${target}`,
    })
}

// 获取用户个人资料 /v1_0/user/profile
export const getUserProfile = () => {
    return request({
        method: 'GET',
        url: '/v1_0/user/profile',
    })
}

// 更新用户资料   /v1_0/user/profile

export const updateUserProfile = data => {
    return request({
        method: 'PATCH',
        url: '/v1_0/user/profile',
        data
    })
}

// 编辑头像 /v1_0/user/photo

export const updateUserPhoto = data => {
    return request({
        method: 'PATCH',
        url: '/v1_0/user/photo',
        data
    })
}